Basic registration, some fixes in logic