Almost done

Almost completed. All restrictions are there. Should work. ToDo: load
from stdin