Cleaned up some nasty code.