Various bugfixes and debuglines added