Fixed some js architecture issues