added setup script, fixed some bugs