Added almost all functions. UI is still under construction.