Added tests, refactored references, fixed typos.