Added important code fixes #1