Continued work on the refractoring/rewrite

There are a few problems with it right now but ill sort them out later
im going to nap now. nini