Changed a lot of things, code is currently in working state