Some bugfixes. Still some issues remaining.