Fixed NullPointerException. Closes #227