a lot of cleaning up, still testing