Bugfixes in last implementation