fixed many aliasing/const-correctness issues