Added more functionality and fixed a lot of bugs.