reordered some files and fixed some small bugs