Work in progress

Remove debug code. change routines to use jquery.