Fixing issues #24, #30 and #31