fixing multiple bugs.