Refactored stuff, currently not working though