several features and bugs fixed