Refactor code, notice bugs