Move 9 functions from window.c