Code refactoring
Refactored binary reader and writer