Fixing some basic things with javascript factories & scopes