Added Buffer class and adapted the rest