Almost finished, and some minor functionmay be added later