fixed many bugs specially related to re-binding. As a consequence, created different functions for page setup and for page refresh