Fix bugs in setting the time zone

This pull request fixes two bugs, which caused errors in setting time zones. See commit logs for details.