Fixed bugs and added more error codes
added more error codes