Cleanup, typing improvements, fix all "unchecked" warnings.