Work in progress
Added most of the functions
Finished initial version. Needs tests