Fixed few bugs

Thx @mdijksta