Design and many small fixes