Added Error codes, Some bugs to be fixed :(