Added error codes and various todos