Fixed some minor bugs that raise warnings/exceptions.