Lots of changes to fit architecture