cache duplicate load

also ensure modules generated are same since they were dynamically
generated.
minor coding style refine