More work done

implemented more of the main body, still not ready for testing