Fix #11. Based off patch by scythetwirler.