Fix Bug and Refactor more