Fixes and working main