Performance improvement by using ring buffer

Signed-off-by: Roman Gille <developer@romangille.com>