Fixed some small potential bugs.