Finalisation and correction of some bugs