Issues 162, 163 and 164

This should solve the issues #162, #163 and #164.