Fixed several bugs.
Added more functionality.