Changed location of consts, closed all (maybe unneeded?) buffers etc.