Bug fixes & code organization