Fix some random bugs
Add copyright