lot of stuff but mostly code clean up and bug fixing