Code Submission

There are most likely bugs but I fixed as many as I can. It's not perfect, but if you notice anything at all, make an issue!

Fix #348 
Fix #346 
Fix #330