Finished code, ready for testing/comments