Fixing issues #14, #15, #16, #17