Added a liscense, removed some cruft, refactored..