fixxed error-handling, comments some functions