main js fix & cleanup