Restructured code, added initial timezone support.