did some TODOs; general refactor