Refactor code.
Use bounds instead of frame wherever required. Add documentation. Remove some magic numbers.