Working but edge cases causing problems.
First commit. Working.