Reduced buffer size, changed remaining globals to private