Various fixes, improvements
Added license, fixes issue #1