fixed bugs, added fix const functionality