added loader.php, added config funcs, fixed some bugs