Cleaned up code, added a few error codes, and added testing page