further javascript improvements and debug.