Bug fixed and cleanup