Fixed a lack of mutex in the last commit. Also fixed some const-