kernel: move functions around, remove unused declarations