Fixed messages and exceptions. Also adapted to work with Java6.