fix all kinds of issues, add debug function
finish some file renames/moves