organized files, added minor fixes to error handling