fixing TODOs and warnings and tidying up