[IMP] Many improvements and bug fixes