Fixed bug: buffer would have been accessed out of bounds (in factorial)