added contractbuffer, restructuring for more efficiency