Refactor

Completely refactored first commit, now works with original schema.
refactor

refactored code to the originally planned way of implmentation.