Clean up and implement some TODOs