Initial version had some bit that didn't exit correctly. Finally debugged and now updated here.
Useful code snippets.