Fix how js objects are copied