Bugs fixed

See commit 4ef1974