Code cleanups

A bunch of minor code improvements that were inspired by Josh Blochs book Effective Java:

* More explicit null pointer checks for method parameters
* Documentation of thrown exceptions
* Copying returned arrays in getters to keep immutability
* More

I hope the whole lot of commits is not too confusing.