Started improving code structure