Update some functions, improve performance