fixbugs & modified housekeeping sh