Bugfix courtesy nicferrier++