Added queue functionality

- Fixed many bugs