Some changes from webERP and various bug fixes