Whitespaces removal and buffer size checks added