Added more functionality and bugfixes.