Fix bugs, extract main()
Drawing tweaks