Refactored initialization

Moved initialization code in function main() into function setup()