fixed buffer being negative 1, loads of comments