Fixed some js and functionality issues