fixed references, jshint errors and more, cleaned up code big time