Try to fix small namespace bug in utils. Switch some imports to be embedded in functions to remove circular import.