Automated a lot of the code

Moste of the code is automated now.