Pretty much works, needs some cleanup.