Huge cleanup, tests addition and stuff.