Fixed several issues due to const changes + unit tests.