added some functions, bugfixes and improvements