Convert core code to OOP

Still incomplete:
- [x] #7
- [x] #8 
- [ ] #9