Updated files, and added test code. May not work completely out-of-box, will check later.