Authomatic buffer size tested. Code cleaned