clean up and added to test functionality

added in framebuffer checking and cleaned up some errors as well as
formatted code