Fix for #874.
Also killed some unused defines that were only confusing.