This whole class needs comments :-)