Const correctness; remove unused kernel code