Fixed bugs from previous version and moved things about to allow better rendering