Start fixing mainscreen code

Was really bad...I'm now in the process of fixing it to something that
make more sense.