Major update (r3)

Object-oriented some of the more complex functions to allow them to
return more data. Various fixes and improvements.