Added all new code (rebase)