Initial tests and some random bug fixes.