add missing files, misc. refactor and debug