Reorganized to get things out from .ready()