Added Alex's changes to fix issue #57