Code cleanup, almost all code was moved frome html files to js