refactor and cleanup

Signed-off-by: Steven Armstrong <steven.armstrong@id.ethz.ch>