- minor refactoring
- reduce memory consumption a bit

Signed-off-by: easymodo <easymodofrf@gmail.com>