Replace int with Uint8
Replace int with Uint8
Remove unused methods
Re-organize and modularize code