partial revert of 8db6b816 and 946d5348
Merge pull request #792 from xdel/fix-crappy-hack

partial revert of 8db6b816 and 946d5348