Additional functionality

Mostly works now, not many bugs left.