Finished testing sources; minor refactoring