cleaned up common.js code + miscellaneous changes