Fixed alot of error handling.