add licence and correct warnings
fix bugs and crash !