Refactored files due to jsint feedback