Lot's of code improvements