stable version after some cleanup and moving external js to lib