code now cleaner, but some functionality broken. WIP