cache scroll vars, make a bit more robust