Refactored stuff, not all of it works