Bug Fixes + code cleanup + Js reorg