Refactor file/msg loading, fix invalid path bug