Fixed bugs #1 and #4