Added error codes so die() use is now deprecated. Added some more documentation.