Fixed interrupt handling, added some basic structures and logic