fixed few bugs, added preloader and error handler, extracted helpers