Resolved errors and restored global vars