Pretty much done. needs commenting