Adding some more functionality, minor bugfixes

Code needs to be cleaned up some more, but you can pull some of this if you want