Initial working version.

General cleanup, pep8/pylint.

Cap check and warn ratio now working.