Bugs #121, #175, #183 and #186 fixed