admin and javascript refactoring + random fixes