Improvements and some bug fixing