Code in functional state

Code works and appears to meet all requirements. It could definitely
benefit from some efforts to refactor and improve efficiency, but given
time availability, this will have to be suitable.