Added type declarations
Made random access for buffers