Refactoring and cleanup.

Switch over to use tools.mk and address open dialyzer warnings.