Add peripheral model and resolve some bugs