Added balance managment. Many fixes and optimisations.