fixed autoloader and added some checks