fixing many bugs!