Fix: const correctness and minor fixes