Refactored the code in an object oriented manner

More work done to tubes...