Major bugfixes and behaviour tweeks.