gold posts modest gains, shakes off early weakness