Fixed some more misc bugs, better error handling