Code with AStyle formatted. Needs some improvements!