Fixed bug identified by Lucas Wagner.