minor reorganization / reordering of variables. move all into jQuery ready