synched with Pavels Code. Missing Display class and possibly others.