rename files and fix some logical bugs